package com.tbit.main.service.impl;

import com.tbit.main.constant.BatteryConstant;
import com.tbit.main.pojo.BatteryGroup;
import com.tbit.main.service.BatteryGroupService;
import com.tbit.main.service.BatteryQuartzService;
import com.tbit.main.util.DateTimeUtil;
import com.tbit.main.util.LogUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author LMY
 * @create 2022-05-23 15:08
 */
@Service("batteryQuartzService")
public class BatteryQuartzServiceImpl implements BatteryQuartzService {

    @Autowired
    private BatteryGroupService batteryGroupService;

    @Override
    //@Scheduled(cron = "0 1/1 * * * ?")
    public void delGroup() {

        LogUtil.info("清理移交电池分组定时任务！");
        long t1 = System.currentTimeMillis();

        List<BatteryGroup> batteryGroupList = batteryGroupService.getType(BatteryConstant.battery_Group_YJ, DateTimeUtil.getMinsAgo(5));

        for (BatteryGroup batteryGroup : batteryGroupList) {
            batteryGroupService.del(batteryGroup.getId());
        }

        long t2 = System.currentTimeMillis();
        LogUtil.info("清理移交电池分组定时任务时间" + (t2 - t1) + "ms");
    }

    @Override
    //@Scheduled(cron = "0 1/10 * * * ?")
    public void delGroupAccountUser() {

        LogUtil.info("清理删除运维人员电池分组定时任务！");
        long t1 = System.currentTimeMillis();

        List<BatteryGroup> batteryGroupList = batteryGroupService.getNOExt();

        for (BatteryGroup batteryGroup : batteryGroupList) {
            batteryGroupService.del(batteryGroup.getId());
        }

        long t2 = System.currentTimeMillis();
        LogUtil.info("清理删除运维人员电池分组定时任务时间" + (t2 - t1) + "ms");
    }


}
